package com.jinzecloud.ordersystem.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.jinzecloud.ordersystem.bean.SpCart;
import com.jinzecloud.ordersystem.service.SpCartService;
import com.jinzecloud.ordersystem.utils.PageUtils;
import com.jinzecloud.ordersystem.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




/**
 * 购物车表
 *
 * @author æ­å°
 * @email 1971240051@qq.com
 * @date 2023-03-27 22:49:46
 */
@RestController
@RequestMapping("dormitory/spcart")
public class SpCartController {
    @Autowired
    private SpCartService spCartService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("dormitory:spcart:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = spCartService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{usCid}")
    //@RequiresPermissions("dormitory:spcart:info")
    public R info(@PathVariable("usCid") Integer usCid){
		SpCart spCart = spCartService.getById(usCid);

        return R.ok().put("spCart", spCart);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("dormitory:spcart:save")
    public R save(@RequestBody SpCart spCart){
		spCartService.save(spCart);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("dormitory:spcart:update")
    public R update(@RequestBody SpCart spCart){
		spCartService.updateById(spCart);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("dormitory:spcart:delete")
    public R delete(@RequestBody Integer[] usCids){
		spCartService.removeByIds(Arrays.asList(usCids));

        return R.ok();
    }

}
